using UnityEngine;

namespace GameCore
{
    public class SimpleGridItem : GridItem
    {
        public bool removable = true;
        public SpriteRenderer image;
        public Vector3 imageOffset;
        public Sprite sprite;

        private void Awake()
        {
            image.sprite = sprite;
            image.transform.localPosition = imageOffset;
        }
        
        public void OnValidate()
        {
            if (image) image.sprite = sprite;
            image.transform.localPosition = imageOffset;
            resourceID.id = sprite.name;
            gameObject.name = sprite.name;
        }
        
        public override void OnClick()
        {
            if (removable) PlayerInputHandler.BeginPlaceGridItem(this);
        }
    }
}